#include "ZFileSystemUtils.h"

#include <QProcess>
#include <QFileInfo>
#include <QDesktopServices>
#include <QUrl>
#include <QDir>

ZFLIB_BEGIN_NAMESPACE

void ZFileSystemUtils::exploreTo(const QString &filepath)
{
    QFileInfo fi(filepath);
    if (fi.isDir())
    {
        QDesktopServices::openUrl(filepath);
    }
    else
    {
        const QString explorer = "explorer.exe";
        QString cmd = "explorer.exe " + QStringLiteral("/select,\"%1\"").arg(QDir::toNativeSeparators(filepath));
        QProcess::startDetached(cmd);
    }
}

ZFLIB_END_NAMESPACE
